import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js'
import XInput from 'vux/src/components/x-input/index.vue'
import Group from 'vux/src/components/group/index.vue'
import Datetime from 'vux/src/components/datetime/index.vue'
import Picker from 'vux/src/components/picker/index.vue'
import Popup from 'vux/src/components/popup/index.vue'

var siteIda = global.siteId

export default {
  name: 'query',
  components: {XInput, Group, Datetime, Picker, Popup},
  data () {
    return {
      applyId: '',
      reason:'',
      showAble: true
    }
  },
  mounted () {
    this.applyId = this.$route.query.applyId
  },
  methods: {
    overModify () {
      var _this = this
      if (_this.showAble) {
        _this.showAble = false
        if (_this.reason == '') {
          _this.showAble = true
          alert('请输入退费原因！')
        } else {
          http.post(CONSTANT.APPLYREFUND, {
            applyId: _this.applyId,
            siteId: sessionStorage.getItem("siteId")
          }, (res) => {
            //alert(JSON.stringify(res))
            //_this.showAble = true
            if (res.applyId != '') {
            http.post(CONSTANT.SAVEREFUND, {
              applyId: res.applyId,
              reason: _this.reason
            }, (res) => {
              //alert(JSON.stringify(res))
              if (res.code == 200) {
              alert('退费申请成功，请等待审核！')
              this.$router.push({path: '/myClass'})
            } else {
              alert(res.errmsg)
            }
          })
          }
        })
        }
      }
    },
    comeBack () {
      window.history.go(-1)
    }
  }
}
